/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
 * gftpio.h
 *
 * Copyright (C) 2008, 2009 Lingtao Pan
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, 
 * Boston, MA 02111-1307, USA.
 */


#ifndef GFTP_IO_H
#define GFTP_IO_H

typedef struct gftp_getline_buffer_tag
{
  char *buffer,
       *curpos;
  size_t max_bufsize,
         cur_bufsize;
  unsigned int eof : 1;
} gftp_getline_buffer;


void    gftp_free_getline_buffer (gftp_getline_buffer **rbuf);
ssize_t gftp_get_line (gftp_request *request, gftp_getline_buffer **rbuf,
                       char *str, size_t len, int fd);
ssize_t gftp_fd_read  (gftp_request * request, void *ptr, 
                       size_t size, int fd);
ssize_t gftp_fd_write (gftp_request * request, const char *ptr, 
                       size_t size, int fd);
ssize_t gftp_writefmt (gftp_request * request, int fd, const char *fmt, ...);
int     gftp_fd_set_sockblocking (gftp_request * request, int fd, 
                                  int non_blocking);
void    gftp_swap_socks (gftp_request * dest, gftp_request * source);

int     gftp_fd_open    (gftp_request * request, const char *pathname, 
                         int flags, mode_t perms);

#endif
